
const metas = [
	{
		type: 'name_tag/blank',
		name: '空白',
		title: (d) => `停顿 ${d.duration / 1000} 秒`,
		color: 'cyan',
		params : [
			{name: 'duration', min: 1},
		],
	},
	{
		type: 'name_tag/cgcr2018_logo',
		name: 'CGCR2018 LOGO',
		title: (d) => 'CGCR 2018 LOGO',
		color: 'orange',
		params : [],
	},
	{
		type: 'name_tag/title_and_content',
		name: '标题和内容',
		title: (d) => `${d.title} / ${d.content}`,
		color: 'green',
		params : [
			{name: 'title'},
			{name: 'content'},
			{name: 'duration', min: 1},
		],
	},
	{
		type: 'name_tag/cgcr2018_bottom',
		name: 'CGCR2018 滚动条',
		title: (d) => `滚动条: ${d.title} > ${d.content}`,
		color: 'red',
		params : [
			{name: 'title'},
			{name: 'content'},
			{name: 'duration', min: 0},
		],
	},
];

/**
 * @param {{id:number,type:string,data:any}} param 
 */
function pluginTitle(param) {
	const meta = metas.filter(m => m.type === param.type)[0];
	return meta ? meta.title(param.data) : param.type;
}

/**
 * @param {{id:number,type:string,data:any}} param 
 */
function pluginType(param) {
	const meta = metas.filter(m => m.type === param.type)[0];
	return meta ? meta.name : param.type;
}

function pluginTagColor(param) {
	const meta = metas.filter(m => m.type === param.type)[0];
	return meta ? meta.color : 'gray';
}

function allPluginsParam() {
	return metas.map(m => {return {name: m.name, type: m.type, params: m.params};});
}

export default {
	pluginTitle, pluginType, pluginTagColor,
	allPluginsParam,
};
